package com.coolw.dynamic.thread.pool.controller;

import com.coolw.common.api.BaseResult;
import com.coolw.common.api.PageResponse;
import com.coolw.dynamic.thread.pool.domain.request.ThreadPoolConfigAddRequest;
import com.coolw.dynamic.thread.pool.domain.request.ThreadPoolConfigPageRequest;
import com.coolw.dynamic.thread.pool.domain.request.ThreadPoolConfigUpdateRequest;
import com.coolw.dynamic.thread.pool.domain.response.ThreadPoolConfigResponse;
import com.coolw.dynamic.thread.pool.service.ThreadPoolConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 线程池配置请求控制层
 *
 * @author coolw
 * @date 2024/5/15 16:21
 */
@RequestMapping("/thread-pool-config")
@RestController
public class ThreadPoolConfigController {

    @Autowired
    private ThreadPoolConfigService configService;

    @PostMapping("/pageList")
    public BaseResult<PageResponse<ThreadPoolConfigResponse>> pageList(@RequestBody ThreadPoolConfigPageRequest request) {
        return BaseResult.success(configService.pageList(request));
    }

    @PostMapping("/save")
    public BaseResult<Boolean> save(@Validated @RequestBody ThreadPoolConfigAddRequest request) {
        return BaseResult.success(configService.save(request));
    }

    @PostMapping("/update")
    public BaseResult<Boolean> update(@Validated @RequestBody ThreadPoolConfigUpdateRequest request) {
        return BaseResult.success(configService.update(request));
    }
}
